import request from '@/utils/request'

// 查询库位信息列表
export function listLocation(query) {
  return request({
    url: '/wms/location/list',
    method: 'get',
    params: query
  })
}

// 查询库位信息详细
export function getLocation(id) {
  return request({
    url: '/wms/location/' + id,
    method: 'get'
  })
}

// 新增库位信息
export function addLocation(data) {
  return request({
    url: '/wms/location',
    method: 'post',
    data: data
  })
}

// 修改库位信息
export function updateLocation(data) {
  return request({
    url: '/wms/location',
    method: 'put',
    data: data
  })
}

// 删除库位信息
export function delLocation(id) {
  return request({
    url: '/wms/location/' + id,
    method: 'delete'
  })
}

// 根据库位编码查询库位信息
export function getLocationByCode(locationCode) {
  return request({
    url: '/wms/location/getByCode/' + locationCode,
    method: 'get'
  })
}

// 根据仓库ID查询库位信息列表
export function getLocationsByWarehouseId(warehouseId) {
  return request({
    url: '/wms/location/getByWarehouseId/' + warehouseId,
    method: 'get'
  })
}

// 根据区域ID查询库位信息列表
export function getLocationsByAreaId(areaId) {
  return request({
    url: '/wms/location/getByAreaId/' + areaId,
    method: 'get'
  })
}

// 检查库位编码是否唯一
export function checkLocationCodeUnique(locationCode, id) {
  const data = {
    locationCode: locationCode
  };
  if (id !== undefined) {
    data.id = id;
  }
  return request({
    url: '/wms/location/checkLocationCodeUnique',
    method: 'post',
    data: data
  })
}

// 导出库位信息
export function exportLocation(query) {
  return request({
    url: '/wms/location/export',
    method: 'get',
    params: query
  })
}